package com.geek.day01;

import java.util.Random;
import java.util.Scanner;

public class ArrayTest03 {
    public static void main(String[] args) {
        Random random = new Random();
        int[] arr = new int[5];
        int[] arrCopy = new int[5];
        Scanner s = new Scanner(System.in);
        for (int i = 0; i < 5; i++) {
            int num = random.nextInt(20) + 1;
            arr[i] = num;
        }
        int index = 0;
        while (true) {
            boolean isExsist = false;
            System.out.println("请输入数字：");
            int sco = s.nextInt();
            for (int i = 0; i < 5; i++) {
                if (sco == arr[i]) {
                    arr[i] = 0;
                    arrCopy[index] = sco;
                    index++;
                    isExsist = true;
                }
            }
            System.out.println(isExsist ? "找到了" : "没找到");
            if (index == 5) {
                break;
            }
        }
        for (int j = 0; j < 5; j++) {
            System.out.print(arrCopy[j] + " ");
        }
    }
}



